import { Injectable } from '@angular/core'

@Injectable({
  providedIn: 'root',
})
export class LocalStorageService {
  get(key: string): object {
    return JSON.parse(localStorage.getItem(key) || '{}') || {}
  }

  set(key: string, value: any): boolean {
    localStorage.setItem(key, JSON.stringify(value))
    return true
  }

  remove(key: string): void {
    localStorage.removeItem(key)
  }

  clear(): void {
    localStorage.clear()
  }
}
